package com.facade;

import java.io.Serializable;

import com.dao.RunningNumberDAO;
import com.model.RunningNumber;

public class RunningNumberFacade implements Serializable {
	private static final long serialVersionUID = 1L;
	
	private RunningNumberDAO rnDAO = new RunningNumberDAO();

	public String getNextRunningNumber(String form) {
		rnDAO.beginTransaction();
		String currentNumber = rnDAO.nextRunningNumber(form);
		rnDAO.closeTransaction();
		return currentNumber;
	}
	
	public void updateRunningNumber(RunningNumber rn) {
		rnDAO.beginTransaction();
		RunningNumber persistedRN = rnDAO.find(rn.getId());
		persistedRN.setCurrentNumber(rn.getCurrentNumber());
		rnDAO.commitAndCloseTransaction();
	}	
	
}
